/******************************************************************************
Purpose: 		To run analysis of country contexts against coefficients of exposure to violence
				and run analysis specified in the paper
Paper Title:	Adolescent Girls’ Safety In and Out of School: 
				Evidence on Physical and Sexual Violence
				from across Sub-Saharan Africa		
Authors:		Evans D.K., Hares S., Holland P. A., and Mendez Acosta A.
Journal:		Journal of Development Studies (forthcoming)
Input:			Country context excel file
Output:			Table of statistics (Log file in PDF and Excel file)
*******************************************************************************/

/**************************************
00. Housekeeping
***************************************/

* clear memory
	version 16.1
	clear
	clear 	matrix
	clear 	mata
	clear 	results
	set		more off
	set 	maxvar 30000

* set path files
	global parentfolder 	"/Users/amina/Dropbox/Amina-Dave/Violence against girls/Adolescent Girls’ Safety In and Out of School_Replication Files"
	
	* FOR EXAMPLE:
	* global parentfolder 	"/Users/Downloads/Adolescent Girls’ Safety In and Out of School_Replication Files"
	

* globals and locals
	global	logfile		"Country context_logfile"	

* log file
	capture log close _all
	log using "$parentfolder/$logfile", replace
	
/**************************************************
 01. Country context regressions
**************************************************/

	import excel "$parentfolder/Country context.xlsx", sheet("data_all percentage") firstrow clear

	* generate gender gap
		gen primary_gg = primary_f - primary_m
		gen secondary_gg = secondary_f - secondary_m
		
	* label variables
		label var lfp_f_ILO 		"Female LFP (ages 15-64) (modeled ILO estimate)"
		label var lfp_f_national 	"Female LFP (ages 15+) (national estimate)"
		label var primary			"Gross primary school enrollment"
		label var primary_gg		"Gender gap in gross primary school enrollment (female - male)"
		label var secondary			"Gross secondary school enrollment"
		label var secondary_gg		"Gender gap in gross secondary school enrollment (female - male)"
		label var violence			"Proportion of women subjected to physical and/or sexual violence in the last 12 months (% of women age 15-49)"
		label var gii				"Gender Inequality Index"
		label var dhs_wifebeating	"Share of women who believe wife beating is justified for at least one reason"

	* column 1: Lifetime experience of physical or sexual violence
		reg coeff_v lfp_f_ILO
		outreg2 using "$parentfolder/Table A19.xls", ///
			replace dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v lfp_f_national
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v primary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v primary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v secondary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v secondary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v violence
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v gii
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v dhs_wifebeating
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

		reg coeff_v lfp_f_ILO lfp_f_national primary primary_gg secondary secondary_gg violence gii dhs_wifebeating
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical or sexual violence")

			
	* column 2: Lifetime experience of physical violence
		reg coeff_pv lfp_f_ILO
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")


		reg coeff_pv lfp_f_national
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv primary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv primary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv secondary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv secondary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv violence
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv gii
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv dhs_wifebeating
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

		reg coeff_pv lfp_f_ILO lfp_f_national primary primary_gg secondary secondary_gg violence gii dhs_wifebeating
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of physical violence")

	* column 3: Lifetime experience of sexual violence
		reg coeff_sv lfp_f_ILO
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv lfp_f_national
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv primary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv primary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv secondary
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv secondary_gg
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv violence
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv gii
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv dhs_wifebeating
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		reg coeff_sv lfp_f_ILO lfp_f_national primary primary_gg secondary secondary_gg violence gii dhs_wifebeating 
		outreg2 using "$parentfolder/Table A19.xls", ///
			append dec(3) label ctitle("lifetime experience of sexual violence")

		
	* close log file and convert to PDF
	
	translate "$parentfolder/$logfile.smcl" "$parentfolder/$logfile.pdf", replace
	
	*************************************** END OF CODE *****************************************
			
